<?php

namespace App\Service\Common;

use App\Exception\ApiException;
use App\Model\CpsWallet;
use App\Model\Spread\SpreadAccount;
use Hyperf\Di\Annotation\Inject;

abstract class SpreadCoinOperateInterface
{
    /**
     *@Inject
     * @var CpsWallet
     */
    protected CpsWallet $cpsWallet;

    /**
     * @Inject
     * @var SpreadAccount
     */
    protected SpreadAccount $spreadAccount;

    /**
     * 检查num是否正确
     * @param $num
     * @return void
     */
    protected function checkNum($num): void
    {
        if ($num < 0) {
            throw new ApiException('数值错误');
        }
    }

    abstract public function inc(
        int $sId,
        string $amount,
        string $argument,
        string $description = ''
    );

    abstract public function dec(
        int $sId,
        string $amount,
        string $argument,
        string $description = ''
    );
}